<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
<%@ page import="java.io.*"%>
<%@ page import="xml.response.*"%>
<%@ page import="xml.root"%>
<%@ page import="util.print.printLogCat"%>
<%@ page import="org.sql.table.*"%>
<%@ page import="xml.var"%>
<%@ page import="java.util.Vector"%>
<%@ page import="java.util.Enumeration"%>
<%@ page import="jqgrid.jqgrid"%>
<%@ page import="util.check"%>
<%@ include file="../../util/paramPrint.jsp" %>
<%@ page trimDirectiveWhitespaces="true" %> 
<%   

    /*********** jqgrid ******************/
		jqgrid jq=new jqgrid();
		jq.setRows(request.getParameter(jqgrid._rows));
		jq.setSord(request.getParameter(jqgrid._sord));
		jq.setSortname(request.getParameter(jqgrid._sortname));
		jq.setPage(request.getParameter(jqgrid._page));
		jq.setOper(request.getParameter(jqgrid._oper));
		jq.setSearch(request.getParameter(jqgrid._search));
		/*************************************/
		
		
		String Task_ID = request.getParameter("Task_ID");
		String User_ID = request.getParameter("User_ID");
		String Task_Type = request.getParameter("Task_Type");
		String Task_Title = request.getParameter("Task_Title");
		String Start_Task_AddTime = request.getParameter("Start_Task_AddTime");
		String End_Task_AddTime = request.getParameter("End_Task_AddTime");
		
		String Start_Task_EndTime = request.getParameter("Start_Task_EndTime");
		String End_Task_EndTime = request.getParameter("Start_Task_EndTime");
		
		String userType=(String)session.getAttribute("User_Type");
		String userID=(String)session.getAttribute("User_ID");
		root root=new root();

		if(userID==null||(userID.equals(""))){
		root.setStatus("false");
		root.setMsg("未登录");
		PrintWriter pw = response.getWriter();
		pw.println(root.getXmlString());
		pw.flush();
		return ;
}

		taskinfo1_1 user=new taskinfo1_1();
		user.setLimit((jq.getPageInt()-1)*jq.getRowsInt(), jq.getRowsInt());
		if(jq.getSortname()!=null&&!jq.getSortname().equals("")){
		user.setOrder(jq.getSortname(),jq.getSord());
		}
			if(userType.equals("1")){
			if(User_ID!=null&&!User_ID.equals("")){
			user.addequwhile("User_ID"," = ",java.net.URLDecoder.decode(User_ID,"UTF-8"));
			}
		
		}else if(userType.equals("2")){
		user.addequwhile("User_ID"," = ",userID);
		}
		 
		user.setResultField("Task_ID").setResultField("Task_Title").setResultField("Task_Content").setResultField("Task_Type").setResultField("Task_AddTime").setResultField("User_ID").setResultField("Info").setResultField("Info");
		if(Task_ID!=null&&(!Task_ID.equals(""))){
		  if(check.isNumeric(Task_ID)){
		   user.addequwhile("Task_ID"," = ",Task_ID);
		  }else{
		    root.setStatus("false");
			root.setMsg("不是正确的ID值");
			PrintWriter pw = response.getWriter();
			pw.println(root.getXmlString());
			pw.flush();
			return ;
		   }
		}
		
		if(Task_Type!=null&&(!Task_Type.equals(""))){
		  
		    user.addequwhile("Task_Type","like","%"+java.net.URLDecoder.decode(Task_Type,"UTF-8")+"%");
		}
		
		if(Task_Title!=null&&(!Task_Title.equals(""))){
		  
		    user.addequwhile("Task_Title","like","%"+java.net.URLDecoder.decode(Task_Title,"UTF-8")+"%");
		}
		
		if(Start_Task_AddTime!=null&&(!Start_Task_AddTime.equals(""))){
		  
		    user.addequwhile("Task_AddTime",">=",Start_Task_AddTime);
		}
		
		if(End_Task_AddTime!=null&&(!End_Task_AddTime.equals(""))){
		  
		    user.addequwhile("Task_AddTime","<=",End_Task_AddTime);
		}
		
		if(Start_Task_EndTime!=null&&(!Start_Task_EndTime.equals(""))){
		  
		    user.addequwhile("Task_EndTime",">=",Start_Task_EndTime);
		}
		
		if(End_Task_EndTime!=null&&(!End_Task_EndTime.equals(""))){
		  
		    user.addequwhile("Task_EndTime","<=",End_Task_EndTime);
		}
		Vector d=user.getTableFactroy();
		root.setRecords(""+d.size());//设置当前查询到的记录数
		int pageNum=user.getCount()/jq.getRowsInt();
		if((user.getCount()%jq.getRowsInt())>0){
			pageNum++;
		}
		root.setTotal_Count(""+pageNum);//查询到的总记录数
		root.setLimit_Offset(""+jq.getPage());//当前查询页面
		for(int i=0;i<d.size();i++){
			taskinfo1_1 u=(taskinfo1_1)d.elementAt(i);
		Enumeration e=u.getTable().elements();
		response res=new response();
		res.setAttribute_Id(""+i);
		for(int j=0;j<u.getResultFieldNum();j++){
			String field=(String)u.getSql().getResultField().elementAt(j);
    		var v=(var)u.getTable().get(field);
    		res.put(v.getName(), v);
		}
		root.addResponse(res);
		}
		//printLogCat.printlnWriter(root.getXmlString());
		String rep=root.getXmlString();
%>
<%=rep%>


